package utils;

import java.io.IOException;
import java.io.InputStream;

import javax.swing.JTextArea;

public class SyncPipe implements Runnable {
	private final InputStream istrm_;
	private JTextArea log;

	public SyncPipe(InputStream istrm, JTextArea log) {
		istrm_ = istrm;
		this.log = log;
	}

	public void run() {
		try {
			final byte[] buffer = new byte[1024];
			for (int length = 0; (length = istrm_.read(buffer)) != -1;) {
				String linha = new String(buffer, 0, length, "cp850");
				log.append(linha);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}